import {
  queryUserList,
  queryPwdTypeList,
  addUser,
  editUser,
  resetPwdPost,
  deleteUserPost,
  queryRoleList,
  addRole,
  editRole,
  deleteRolePost,
  systemNameListPost,
  queryDeptList,
  queryMenuList,
  addMenuPost,
  editMenuPost,
  deleteMenuPost,
  addDeptPost,
  editDeptPost,
  deleteDeptPost,
  queryRoleManList,
  batUserRolePost,
  editUserRolePost,
  queryRoleAuthList,
  batUserRoleAuthPost,
  editUserRoleAuthPost,
  editAdminUserRolePost,
  editAdminUserRoleAuthPost,
  batAdminUserRolePost,
  batAdminUserRoleAuthPost,
  queryDictList,
  editDictPost,
  addDictPost,
  deleteDictPost,
  queryDictKeyList,
  addKeyDictPost,
  editKeyDictPost,
  deleteKeyDictPost
} from './../services/system'

export default {
  namespace: 'system',
  state: {
    
  },

  subscriptions: {
    // setup({ dispatch, history }) {
    //   dispatch({
    //     type: 'queryAddressJson',
    //     payload: {},
    //   })
    // },
  },

  effects: {
    *queryUserList({ payload }, { call }) {
      const data = yield call(queryUserList, payload)
      // const { success, message, status, ...other } = data
      return data
      // if (success) {
      //   return data
      // } else {
      //   throw data
      // }
    },
    *queryPwdTypeList({ payload }, { call }) {
      const data = yield call(queryPwdTypeList, payload)
      // const { success, message, status, ...other } = data
      return data
      // if (success) {
      //   return data
      // } else {
      //   throw data
      // }
    },
    *addUser({ payload }, { call }) {
      const data = yield call(addUser, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editUser({ payload }, { call }) {
      const data = yield call(editUser, payload)
      const { success, message, code, ...other } = data
      return data
    },
    *resetPwdPost({ payload }, { call }) {
      const data = yield call(resetPwdPost, payload)
      const { success, message, code, ...other } = data
      return data
    },
    *deleteUserPost({ payload }, { call }) {
      const data = yield call(deleteUserPost, payload)
      const { success, message, code, ...other } = data
      return data
      // if (success) {
      //   return data
      // } else {
      //   throw data
      // }
    },
    *queryRoleList({ payload }, { call }) {
      const data = yield call(queryRoleList, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *addRole({ payload }, { call }) {
      const data = yield call(addRole, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editRole({ payload }, { call }) {
      const data = yield call(editRole, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *deleteRolePost({ payload }, { call }) {
      const data = yield call(deleteRolePost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *systemNameListPost({ payload }, { call }) {
      const data = yield call(systemNameListPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *queryDeptList({ payload }, { call }) {
      const data = yield call(queryDeptList, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *queryMenuList({ payload }, { call }) {
      const data = yield call(queryMenuList, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *addMenuPost({ payload }, { call }) {
      const data = yield call(addMenuPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editMenuPost({ payload }, { call }) {
      const data = yield call(editMenuPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *deleteMenuPost({ payload }, { call }) {
      const data = yield call(deleteMenuPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *addDeptPost({ payload }, { call }) {
      const data = yield call(addDeptPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editDeptPost({ payload }, { call }) {
      const data = yield call(editDeptPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *deleteDeptPost({ payload }, { call }) {
      const data = yield call(deleteDeptPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *queryRoleManList({ payload }, { call }) {
      const data = yield call(queryRoleManList, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *batUserRolePost({ payload }, { call }) {
      const data = yield call(batUserRolePost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editUserRolePost({ payload }, { call }) {
      const data = yield call(editUserRolePost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *queryRoleAuthList({ payload }, { call }) {
      const data = yield call(queryRoleAuthList, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *batUserRoleAuthPost({ payload }, { call }) {
      const data = yield call(batUserRoleAuthPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editUserRoleAuthPost({ payload }, { call }) {
      const data = yield call(editUserRoleAuthPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editAdminUserRolePost({ payload }, { call }) {
      const data = yield call(editAdminUserRolePost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editAdminUserRoleAuthPost({ payload }, { call }) {
      const data = yield call(editAdminUserRoleAuthPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *batAdminUserRolePost({ payload }, { call }) {
      const data = yield call(batAdminUserRolePost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *batAdminUserRoleAuthPost({ payload }, { call }) {
      const data = yield call(batAdminUserRoleAuthPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *queryDictList({ payload }, { call }) {
      const data = yield call(queryDictList, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editDictPost({ payload }, { call }) {
      const data = yield call(editDictPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *addDictPost({ payload }, { call }) {
      const data = yield call(addDictPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *deleteDictPost({ payload }, { call }) {
      const data = yield call(deleteDictPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *queryDictKeyList({ payload }, { call }) {
      const data = yield call(queryDictKeyList, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *addKeyDictPost({ payload }, { call }) {
      const data = yield call(addKeyDictPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *editKeyDictPost({ payload }, { call }) {
      const data = yield call(editKeyDictPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
    *deleteKeyDictPost({ payload }, { call }) {
      const data = yield call(deleteKeyDictPost, payload)
      // const { success, message, status, ...other } = data
      return data
    },
  },
  reducers: {
    setState(state, action) {
      return {
        ...state,
        ...action.payload,
      }
    },
  },
}
